import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * User: thoughtworker
 * Date: 10/10/13
 * Time: 3:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class MenuHandler {

    private BufferedReader reader;
    private PrintStream printer;
    private String userInput;
    private Collection<String> menuOptions = Arrays.asList("View all players", "View all coaches", "Find a player");
    private League league;

    public MenuHandler(PrintStream printstream, BufferedReader reader, League league) {
        this.printer = printstream;
        this.reader = reader;
        this.league = league;
    }

    public void displayMenu() {
        for(String option : menuOptions){
            printer.println(option);
        }
    }

    public String grabUserInput() throws IOException {
        return reader.readLine();
    }

    public void respondToUserInputOnMainMenu(String userInput) throws IOException {
        if (userInput.equals("View all players")) {
            league.displayInfoOfAllPlayers();
        } else if (userInput.equals("View all coaches")) {
            league.displayInfoOfAllCoaches();
        } else if (userInput.equals("Find a player")) {
            respondToUserInputOnFindAPlayer();
        }
    }

    private void respondToUserInputOnFindAPlayer() throws IOException {
        printer.println("Please type the name of the player: ");
        String nameOfPlayerToFind = grabUserInput();
    }

}
